package br.com.vfsb.controller;

import java.util.List;
import java.util.Map;

import org.hibernate.Transaction;
import org.primefaces.model.LazyDataModel;

import br.com.vfsb.dao.CompraLocalDAO;
import br.com.vfsb.entity.CompraLocal;

public class LazyCompraLocal extends LazyDataModel<CompraLocal>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<CompraLocal> cl;
	private Transaction tx;
	private CompraLocal compraLocal;
	private CompraLocalDAO dao;
	/*
	@Override
	public List<CompraLocal> load(int startingAt, int maxPerPage, String sortField, SortOrder sortOrder, Map<String, String> filters) {
		try {
			try {
				
				// with datatable pagination limits
				cl = dao.findPlayers(startingAt, maxPerPage);

				// If there is no player created yet, we will create 100!!
				if (cl == null || cl.isEmpty()) {
					//dao.create100Players();
					
					// we will do the research again to get the created players
					cl = dao.findPlayers(startingAt, maxPerPage);
				}
			} finally {
				tx.commit();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		// set the total of players
		if(getRowCount() <= 0){
			setRowCount(dao.countPlayersTotal());
		}
		
		// set the page dize
		setPageSize(maxPerPage);

		return cl;
	}
	
	
	
	

	public List<CompraLocal> getCl() {
		return cl;
	}

	public void setCl(List<CompraLocal> cl) {
		this.cl = cl;
	}

	public Transaction getTx() {
		return tx;
	}

	public void setTx(Transaction tx) {
		this.tx = tx;
	}

	public CompraLocal getCompraLocal() {
		return compraLocal;
	}

	public void setCompraLocal(CompraLocal compraLocal) {
		this.compraLocal = compraLocal;
	}

	public CompraLocalDAO getDao() {
		return dao;
	}

	public void setDao(CompraLocalDAO dao) {
		this.dao = dao;
	}

	
	
*/	

}
